home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0056_Images.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  2KB  |  79 lines

  1. {
  2. -> I'm trying to use the GetImage and PutImage commands from Turbo
  3. -> Pascal
  4.  
  5. Okay.. did you declare a varible that would hold the size you needed? I
  6. have a little program I wrote to draw a musical staff and put the notes
  7. up randomly so that I can practice reading music..
  8. }
  9.  
  10. Program MusicNotes;
  11.  
  12. Uses
  13.   Crt,
  14.   Dos,
  15.   Graph,
  16.   XtraDos;
  17.  
  18. const
  19.   NotePos : Array[1..11] Of Integer =
  20. (164,179,194,209,224,239,254,269,284,299,314);
  21.   Note : Array[1..11] Of Char =
  22. ('G','F','E','D','C','B','A','G','F','E','D');
  23.  
  24. Procedure Beep;
  25.  
  26. begin
  27.   sound(600);
  28.   delay(100);
  29.   nosound;
  30. end;
  31.  
  32. var
  33.   CallUnit : CallH;
  34.   Key : Char;
  35.   P : Pointer;
  36.   Size : Word;
  37.   Y, X,
  38.   MaxX, MaxY,
  39.   grMode,
  40.   grDriver : Integer;
  41.  
  42. Begin
  43. grDriver := Detect;
  44. InitGraph(grDriver, grMode,'D:\bp\bgi');
  45. MaxX:=GetMaxX;
  46. MaxY:=GetMaxY;
  47. SetColor(white);
  48. Circle(15,15,15);
  49. FloodFill(15,15,white);
  50. Size:=ImageSize(0,0,30,30);
  51. GetMem(P,Size);
  52. getImage(0,0,30,30,P^);
  53. cleardevice;
  54. Y:=((MaxY Div 2)-60);
  55. For X:=1 To 5 Do
  56.  Begin
  57.   Line(0,Y,MaxX,Y);
  58.   Y:=Y+30;
  59.  End;
  60. Randomize;
  61. Repeat
  62. X:=Random(11)+1;
  63.   PutImage(320,(NotePos[X]-15),P^,ORPut);
  64.   Repeat
  65.    Key:=Char(CallUnit.KeyReturn);
  66.   Until Key=Note[X];
  67.   Beep;
  68.   PutImage(320,(NotePos[X]-15),P^,XOrPut);
  69.   If (X/2)=(X Div 2) Then
  70.     Line(290,NotePos[x],350,NotePos[x])
  71.     Else
  72.      If X>1 Then
  73.        Line(290,NotePos[x-1],350,NotePos[x-1]);
  74. Until 3=2;
  75. End.
  76.  
  77. The important part is the SIZE=.. Use that line to create a varbible
  78. buig enough to hold the image.
  79.